package com.xintonghua.bussiness.ui.fragment.client.user;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.base.BaseActivity;
import com.xintonghua.bussiness.bean.Contant;
import com.xintonghua.bussiness.bean.HairdressingTestBean;
import com.xintonghua.bussiness.bean.MeiRongTestContentBean;
import com.xintonghua.bussiness.bean.ResultScore;
import com.xintonghua.bussiness.ui.home.DialogQueRenQianZiActivity;
import com.xintonghua.bussiness.util.JumpUtils;
import com.xintonghua.bussiness.util.MyState;
import com.xintonghua.bussiness.util.MyUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DialogMeiYunTestJieGuoActivity extends BaseActivity {

    @BindView(R.id.tv_titles)
    TextView tvTitles;
    @BindView(R.id.tv_jieguo)
    TextView tvJieguo;
    @BindView(R.id.tv_jianyi)
    TextView tvJianyi;
    @BindView(R.id.tv_score)
    TextView tvScore;
    @BindView(R.id.btn_ok)
    Button btnOk;

    Contant contantbean;
    HairdressingTestBean bean;
    ResultScore resultScore;

    List<MeiRongTestContentBean> list_bean;
    Double zongfen = 0.0;

    ArrayList<Integer> xuanzhonglist = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mei_yun_test_jie_guo);
        ButterKnife.bind(this);
        contantbean = (Contant) JumpUtils.getSerializable(this, "data0");
        bean = (HairdressingTestBean) JumpUtils.getSerializable(this, "data1"); //bun.putSerializable("data1", bean);
        list_bean = (List<MeiRongTestContentBean>) JumpUtils.getSerializable(this, "data2");
        zongfen = JumpUtils.getDouble(this, "zongfen", 0);
        xuanzhonglist = getIntent().getIntegerArrayListExtra("xuanxianglist");
        resultScore = (ResultScore) getIntent().getSerializableExtra("data3");
        tvScore.setText("" + zongfen);
        tvTitles.setText(resultScore.getName()+"测试结果");
        tvJieguo.setText(resultScore.getTitle());
        tvJianyi.setText(resultScore.getRemark());
    }

    @OnClick(R.id.btn_ok)
    public void onViewClicked() {
        String choice = "";
        for (int i = 0; i < list_bean.size(); i++) {
//            for (int j = 0; j < list_bean.get(i).getChoice().size(); j++) {`
            if (i == 0)
                choice = list_bean.get(i).getChoice().get(xuanzhonglist.get(i)).getChoose();
            else {
                choice = choice + "," + list_bean.get(i).getChoice().get(xuanzhonglist.get(i)).getChoose();
            }
//            }
        }

        httpCent.saveBeautyHistoryScore("" + contantbean.getId(), bean.getId(), choice, "" + zongfen, this, MyState.requestOne);
    }

    @Override
    public void dataBack(Object data, int order) {
        super.dataBack(data, order);
        try {
            switch (order) {
                case MyState.requestOne:
                    MyUtils.mToast(DialogMeiYunTestJieGuoActivity.this, "保存成功");
                    finish();
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
